﻿using System;

namespace FuzzScript
{
    class PredicateClause : Node
    {
        private PredicateClause(){}

        internal PredicateClause(string p_sPredicateName)
        {
            // clause has one sibling, the actual predicate
            m_SiblingNodes.Add(null);

            m_sName = p_sPredicateName;

            m_SiblingNodes[0] = (SymbolTable.Instance.Get(
                SymbolTable.AttributePredicateValue(m_sName)));
        }

        public override string ToString()
        {
            return "Pred<" + m_sName + ">";
        }

        public override double Execute()
        {
            return ((IDOMValueNode)m_SiblingNodes[0]).DOMValue;
        }

        public override void AddSibling(INode p_SiblingNode)
        {
            throw new Exception("Attempted to add a predicate to a PredicateClause");
        }

        public override string Generate()
        {
            return SymbolTable.AttributePredicateValue(m_sName);
        }
    }
}
